<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSeecmsUserTable extends Migration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */

    protected $name = 'seecms_user';

    public function up()
    {
        Schema::create($this->name, function (Blueprint $table) {
            $table->id();
            $table->string('username', 32)->comment('登录账号')->unique();
            $table->string('password', 64)->comment('登录密码');
            $table->string('nickname', 64)->comment('昵称')->default('');
            $table->string('avatar')->comment('头像')->default('');
            $table->char('phone', 11)->unique();
            $table->string('email', 64)->default('');
            $table->tinyInteger('tries')->comment('尝试登录次数')->default(0);
            $table->dateTime('last_login_time')->comment('最后登录时间')->nullable();
            $table->string('last_login_ip')->comment('最后登录时间')->default('');
            $table->char('encrypt', 32);
            $table->string('wechat_openid', 64)->comment('微信授权id')->default('');
            $table->tinyInteger('status')->comment('用户状态')->default(1);
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists($this->name);
    }
}
